#include <stdio.h>
#include <stdlib.h>


void rotate(int* nums, int numsSize, int k){
	int* newnums = (int *)malloc(sizeof(nums[0]) * numsSize);
	if (numsSize == 1 || NULL == nums){
		return;
	}
	for (int i = 0; i < numsSize; i++){
		newnums[(i + k) % numsSize] = nums[i];
	}
	for (int i = 0; i < numsSize; i++){
		nums[i] = newnums[i];
	}
	free(newnums);
}

/*
void Swap(int* p, int* q)
{
	*p ^= *q;
	*q ^= *p;
	*p ^= *q;
}

void Reverse(int* nums, int start, int end)
{
	while (start < end){
		Swap(&nums[start++], &nums[end--]);
	}

}

void rotate(int* nums, int numsSize, int k)
{
	k %= numsSize;
	Reverse(nums, 0, numsSize - 1);
	Reverse(nums, 0, k - 1);
	Reverse(nums, k, numsSize - 1);
}
*/


int main()
{
	int nums[] = { 1, 2, 3, 4, 5, 6, 7 };
	rotate(nums, 7, 3);
	return 0;
}